home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
editdemo
/
editdemo.doc
next >
Wrap
Text File
|
1991-07-04
|
4KB
|
119 lines
(c) 1991 by Keith Milligan
100 Lee Road 605
Smiths, AL 36877
205-291-9712 Home
205-298-1974 Work
Compuserve ID = 70645,520
Use these routines if they will help you. You can use,
modify, copy, or distribute with a clear concience.
Visual Basic 1.0 input routines
These routine are use two events for each text control.
There is a Sub for the KeyPress event and a corresponding
Function for the LostFocus Event. The KeyPress (KP) routine
restricts certain keystrokes and the LostFocus (LF) routine
validates the data entered in the text control and assigns
the entered data to a variable.
Date
Sub DateKP(ThisControl, KeyAscii)
Function DateLF$(ThisControl, EarliestDate$)
Format of EarliestDate$ is "yymmdd".
Accepts date enter in one of the following formats:
60491, 060491, 06/04/91, or 6/4/91
Returns date in the format 910604.
MultPrice
Sub MultPriceKP(ThisControl, KeyAscii)
Function MultPriceLF$(ThisControl)
Used to accept retail prices. For example 3 for $1.00.
Accepts and returns in the following formats:
Input Returns
149 01/01.49
1.49 01/01.49
3/49 03/00.49
3/.49 03/00.49
Point2
Sub Point2KP(ThisControl, Length%, KeyAscii)
Function Point2LF(ThisControl, Min#, Max#)
Accepts number with two digits to the right of the decimal point.
Maximum length = Length%
Minimum value = Min#
Maximum value = Max#
Example 123.49
Point4
Sub Point4KP(ThisControl, Length%, KeyAscii)
Function Point4LF(ThisControl, Min#, Max#)
Accepts number with four digits to the right of the decimal point.
Maximum length = Length%
Minimum value = Min#
Maximum value = Max#
Example 123.4978
Str
Sub StrKP(ThisControl, Length%, KeyAscii)
No LF function for this routine just move text to string in
LostFocus Event.
Accepts string of length less than or equal to Length%.
UCStr
Sub UCStrKP(ThisControl, Length%, KeyAscii)
No LF function for this routine just move text to string in
LostFocus Event.
Accepts string of length less than or equal to Length%.
Converts characters to upper case as typed.
Long
Sub LongKP(ThisControl, Length%, KeyAscii)
Function LongLF&(ThisControl, Min&, Max&)
Accepts long integer amount.
Int
Sub IntKP(ThisControl, Length%, KeyAscii)
Function IntLF%(ThisControl, Min%, Max%)
Same as Long but accepts normal integer amounts
Curr2
Sub Curr2KP(ThisControl, Length%, KeyAscii)
Function Curr2LF@(ThisControl, Min@, Max@)
Same as Point2 but for currency data type.
Curr4
Sub Curr4KP(ThisControl, Length%, KeyAscii)
Function Curr4LF(ThisControl, Min@, Max@)
Same as Point4 but for currency data type.
DateSer
Sub DateSerKP(Thiscontrol, KeyAscii)
Function DateSerLF@(ThisControl, EarliestDate$)
Same as Date but returns date serial number instead of yymmdd.
Calling example:
To call the Point4 routines.
1. In the KeyPress event of the text box control with the CtlName
"Text1" enter the following Sub.
Sub Text1_KeyPress(KeyAscii As Integer)
Point4KP Text1, 10, KeyAscii
End Sub
This accepts a number with up to four decimal places and up to
a length of 10 characters.
2. In the LostFocus event of the same text box control enter the
following Function.
Sub Text1_LostFocus()
CostAmount# = Point4LF(Text1, 1, 1000)
End Sub
This sets CostAmount# to the entered amount if the number
entered is between 1 and 1000. If it is out of range you are
given a warning message box.
The demo program EDITDEMO.EXE must have "vbrun100.dll" available.
It comes with Visual Basic or is available for downloading in the
Microsoft forum's Visual Basic library.